using System.ComponentModel;
using System.Data;
using Dimok.Data.DataSources;

namespace Data.DataSources {
	public class ContractHoldersDataSource : ObjectDataSourceBase {
		public const string CONTRACT_CONDITION_CODE = "ConditionsCode";
		[Bindable(true)]
		public int ContractHolderID { 
			set { 
				SetSelectParameter("ID", value);
				RemSelectParameter(CONTRACT_CONDITION_CODE);
			} 
		}
		[Bindable(true)]
		public string ConditionsCode { 
			set {
				if (value.Trim() == "") RemSelectParameter(CONTRACT_CONDITION_CODE);
				else {
					SetSelectParameter(CONTRACT_CONDITION_CODE, value);
					RemSelectParameter("ID");
				}
			} 
		}
		public override string SelectViewName { get { return "v_ContractHolder"; } }
		public override string InsertViewName { get { return "t_ContractHolder"; } }
		public override System.Data.DataView SelectEx(int ID) {
			return ID == 0 ? SelectEx() : base.SelectEx(ID);
		}
		public DataView SelectEx(string ConditionsCode) {
			return Select(CONTRACT_CONDITION_CODE + "=@Code", ConditionsCode);
		}
	}
}